function [isThere loadedStruct] = ifFileExistThenLoad(structFilename)

bfFiles = dir('./');
fileIndex = find(~[bfFiles.isdir]);
nbFilesCurrent = length(fileIndex);

isThere = 0;
for i=1:nbFilesCurrent
    filename = bfFiles(fileIndex(i)).name;
    xmlFilename = [structFilename,'.xml'];
    matFilename = [structFilename,'.mat'];
    if(length(filename) == length(xmlFilename))
        if(strcmp(filename,xmlFilename))
            isThere = 1;
            break;
        end
        if(strcmp(filename,matFilename))
            isThere = 2;
            break;
        end
    end
end

if(isThere==1)
    loadedStruct = loadStruct(structFilename);
else
    if(isThere==2)
        loadedStruct = load(matFilename,'-mat');
    else
        loadedStruct = [];
    end
end